<!-- AdvertisementItem.vue -->
<template>
  <div class="adv-item-block">
    <div>
      <div class="adv-title1-row">
        <div>
          <span class="title">{{ title }}</span>
          <span>{{ subTitle }}</span>
        </div>
        <div class="text-primary pointer-cursor">
          <span
            v-if="index == 1"
            @click="
              () =>
                router.push({
                  path: '/serviceCenter/resourceDownload',
                  query: { ids: [id], parentId: parentId, id: id },
                })
            "
            >{{ downText }}｜</span
          >
          <span v-if="index == 0" @click="onlineClassListening(id, index)">{{
            linkText
          }}</span>

          <el-tooltip v-else class="box-item" effect="light" placement="bottom">
            <template #content>
              <div class="content-box">
                <router-link
                  v-for="(item, index) in cuccpExamList"
                  :key="item.id"
                  :to="item.url"
                >
                  <p>{{ item.name }}</p>
                </router-link>
              </div>
            </template>
            <span> {{ linkText }} </span>
          </el-tooltip>
        </div>
      </div>
      <div class="adv-item-cover">
        <div class="adv-item-cover-image">
          <img
            class="adv-item-img"
            @load="$emit('image-load')"
            @click="onlineClassListening(id, index)"
            :src="imageSrc"
            alt="广告图片"
          />
        </div>
      </div>
      <div class="adv-item-info">
        <div class="adv-title2">
          <p
            class="title text-hover-primary one-line-show"
            @click="onlineClassListening(id, index)"
          >
            {{ infoTitle }}
          </p>
          <div class="one-line-show">
            <span>{{ speaker }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
const router = useRouter();
const emit = defineEmits(['onlineClassListening', 'image-load']);
defineProps({
  parentId: Number,
  id: Number,
  title: String,
  linkText: String,
  downText: String,
  subTitle: String,
  imageSrc: String,
  infoTitle: String,
  speaker: String,
  index: Number,
  cuccpExamList: Array,
});

// 在线听课  打开二维码弹窗  需要传递两层父级组件
const onlineClassListening = (id, index) => {
  emit('onlineClassListening', id, index);
};
</script>

<style scoped lang="scss" src="./index.scss"></style>
